package tianrun.ziguan.api.calculate.config.service.template.module.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Service;
import tianrun.ziguan.api.calculate.config.dao.TIndicatorsModuleMapper;
import tianrun.ziguan.api.calculate.config.entity.TIndicatorsModule;
import tianrun.ziguan.api.calculate.config.service.template.module.ITIndicatorsModuleService;
import tianrun.ziguan.api.calculate.config.utils.CollectionUtil;

import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
 * @author zhaoqi
 */
@Service
public class TIndicatorsModuleServiceImpl extends ServiceImpl<TIndicatorsModuleMapper, TIndicatorsModule> implements ITIndicatorsModuleService {

    @Override
    public List<TIndicatorsModule> getByTemplate(Set<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return list(Wrappers.<TIndicatorsModule>lambdaQuery().in(TIndicatorsModule::getTemplateId, ids));
    }

    @Override
    public List<TIndicatorsModule> getByIds(Set<Long> moduleIds) {
        if (CollectionUtil.isEmpty(moduleIds))return Lists.newArrayList();
        return list(Wrappers.<TIndicatorsModule>lambdaQuery().in(TIndicatorsModule::getId,moduleIds));
    }
}
